Page({
  data: {
    h:0
  },
  onLoad(){
    const self =this;
    wx.getSystemInfo({
      success: function(res) {
        self.setData({
          h:res.windowHeight
        })
      }
    });
  },
  bindFormSubmit: function(e) {
    const thing9 = e.detail.value.textarea.trim()
    if(thing9==""){
      wx.showToast({
        title: '内容不能为空！',
        icon: 'error'
      });
      return;
    }
    console.log(thing9)
    wx.requestSubscribeMessage({
      tmplIds: ['aBofa4-_Mj_6WEYZWV86_1ebouVQ3xAVxCPp11tqunw'],
      success (res) {
        if(res['aBofa4-_Mj_6WEYZWV86_1ebouVQ3xAVxCPp11tqunw']=="accept"){
          wx.request({
            url: 'https://zdw666.fun/wjy/addMessage',
            method:"POST",
            data:{
              "touser":wx.getStorageSync('openid'),
              "data":{
                "name1":{
                  "value":wx.getStorageSync('username')
                },
                "thing9":{
                  "value":thing9
                }
              }
            },success(res){
              console.log(res)
              if(res.data.code==200){
                wx.showToast({  
                  title: '反馈提交成功',  
                  icon: 'success',  
                  duration: 2000,  
                  success: function () {  
                    // 弹窗显示成功后，设置定时器  
                    setTimeout(() => {  
                      wx.navigateBack({  
                        delta: 1 // 这里你可以根据需要调整返回的页面数  
                      });  
                    }, 2000); // 与弹窗持续时间一致  
                  }  
                });
              }else{
                wx.showToast({
                  title: '网络异常',
                  icon: 'error'
                });
              }
            },fail(error){
              console.log(error)
              wx.showToast({
                title: '网络异常',
                icon: 'error'
              });
            }
          })
        }else{
          wx.showToast({
            title: '用户取消反馈',
            icon: 'error'
          });
        }
      }
    })
  },
});